﻿using Fantasy;
using Fantasy.Async;
using Fantasy.Network.Interface;

namespace Entity.Handler.CustomRouteHandler;

/// <summary>
/// 在聊天服务器下测试用的实体
/// </summary>
public class ChatEntity : Fantasy.Entitas.Entity
{
    public string Name = "Chat";
}
/// <summary>
/// 这是聊天服务器下的和gate服务器的初次连接请求
/// 通过这个请求能把聊天Scene下的某个实体的唯一标识发送给gate服务器，并和gate建立连接
/// </summary>
public class G2Chat_ConnectRequestHandler : RouteRPC<Scene, G2Chat_ConnectRequest,Chat2G_ConnectResponse>
{
    protected override async FTask Run(Scene scene, G2Chat_ConnectRequest request, Chat2G_ConnectResponse response, Action reply)
    {
        var chatEntity = Fantasy.Entitas.Entity.Create<ChatEntity>(scene,true,true);
        response.routeId = chatEntity.RunTimeId;
        await FTask.CompletedTask;
    }
}